<?php
/**
 * Created by PhpStorm.
 * User: cc
 * Date: 2022/9/26
 * Time: 2:59 PM
 */

namespace App\Models\CacheModel;

use App\Models\Api\BaseCache;
use think\Log;

class SystemAsoStartLog extends BaseCache
{
    protected $table = 'wechatadmin.system_aso_start_log';

    public function saveData(array $param)
    {
        $idfa = $param['idfa'];
        $param = json_encode($param, true);
        try
        {
            $log = [
                'header' => json_encode(request()->header()),
                'method' => request()->method(),
                'param' => $param,
                'path' => request()->path(),
                'idfa' => $idfa,
                'time' => time(),
            ];

            $id = $this->insertData($log);
        }
        catch (\Exception $e)
        {
            Log::write("通知任务开始接口日志添加失败:{$param},文件信息:{$e->getFile()} : {$e->getLine()}", 'error', true);
            return 0;
        }
        return $id;
    }
}
